Define Configuration Schema
This feature allows you to define a JSON schema for the configuration of conventional changelog tools. The schema includes properties like 'types', which is an array of objects specifying the type of commit, the section it belongs to, and whether it should be hidden.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Conventional Changelog Config",
"type": "object",
"properties": {
"types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": { "type": "string" },
"section": { "type": "string" },
"hidden": { "type": "boolean" }
},
"required": ["type", "section"]
}
}
},
"required": ["types"]
}
Validate Configuration
This feature allows you to validate a configuration object against the defined schema using a JSON schema validator like Ajv. It ensures that the configuration adheres to the specified structure and required fields.
const Ajv = require('ajv');
const ajv = new Ajv();
const schema = require('conventional-changelog-config-spec');
const validate = ajv.compile(schema);
const config = {
types: [
{ type: 'feat', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' }
]
};
const valid = validate(config);
if (!valid) console.log(validate.errors);